package cn.sc.allinpay.allfavour.business.cashiertransonline;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

import cn.pai.mvp.callback.MpCallBack;
import cn.sc.allinpay.allfavour.base.connect.http.AppRequest;
import cn.sc.allinpay.allfavour.base.connect.http.RequestManager;
import cn.sc.allinpay.allfavour.base.model.BaseModel;
import cn.sc.allinpay.allfavour.business.common.data.OilListRecord;

/**
 * 交易流水
 * author：pany
 * on 2017/12/5 14:44
 */
public class CashierTransOnlineModel extends BaseModel {
    /**
     * 加油订单列表查询
     *
     * @param payNum   订单号
     * @param mpCallBack
     */
    public void reqQueryOilList(String payNum, final MpCallBack<List<OilListRecord>, String> mpCallBack) {
        RequestManager.reqQueryOilList(payNum, new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                if (response.getString("code").equals("0000")) {
                    List<OilListRecord> oilListRecords = response.getJSONArray("data").toJavaList(OilListRecord.class);
                    mpCallBack.onSuccess(oilListRecords);
                } else {
                    mpCallBack.onFailure(response != null ? response.toString() : null, response.getString("msg"));
                }
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }
}
